package com.google.code.jholidays.events.properties;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;

import org.junit.Test;

import com.google.code.jholidays.core.EventDescriptor;
import com.google.code.jholidays.events.parameters.DayMonthPair;
import com.google.code.jholidays.events.properties.FixedEventProperties;


public class FixedEventPropertiesTest {

    @Test(expected = IllegalArgumentException.class)
    public void testNullDescriptor() {
	DayMonthPair pair = new DayMonthPair(1, 1);
	FixedEventProperties props = new FixedEventProperties(null, pair);
	assertNull(props);
    }

    @Test(expected = IllegalArgumentException.class)
    public void testNullPair() {
	EventDescriptor descriptor = new EventDescriptor(1);
	FixedEventProperties props = new FixedEventProperties(descriptor, null);
	assertNull(props);
    }

    @Test
    public void testFixedEventProperties() {
	DayMonthPair pair = new DayMonthPair(1, 1);
	EventDescriptor descriptor = new EventDescriptor(1);
	FixedEventProperties props = new FixedEventProperties(descriptor, pair);
	assertNotNull(props);
    }

    @Test
    public void testGetDayMonth() {
	DayMonthPair pair = new DayMonthPair(1, 1);
	EventDescriptor descriptor = new EventDescriptor(1);
	FixedEventProperties props = new FixedEventProperties(descriptor, pair);
	assertNotNull(props);

	DayMonthPair pair2 = props.getDayMonth();
	assertNotNull(pair2);
	assertSame(pair, pair2);
    }

    @Test
    public void testGetDescriptor() {
	DayMonthPair pair = new DayMonthPair(1, 1);
	EventDescriptor descriptor = new EventDescriptor(1);
	FixedEventProperties props = new FixedEventProperties(descriptor, pair);
	assertNotNull(props);

	EventDescriptor descriptor2 = props.getDescriptor();
	assertNotNull(descriptor2);
	assertSame(descriptor, descriptor2);
    }

    @Test
    public void testGetParent() {
	DayMonthPair pair = new DayMonthPair(1, 1);
	EventDescriptor descriptor = new EventDescriptor(1);
	FixedEventProperties props = new FixedEventProperties(descriptor, pair);
	assertNotNull(props);

	assertNull(props.getParent());
    }

}
